""" Hames: a functional testing framework for Google App Engine Python

Docs and examples: http://code.google.com/p/hames/

Copyright 2012 VendAsta Technologies Inc.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


Main module for hames implementation.

This module should be specified as a handler for fantasm URLs in app.yaml:

  handlers:
  - url: /hames/.*
    login: admin
    script: hames.main.APP
"""

import webapp2
# from google.appengine.ext.webapp2 import util
# from hames import handlers

def createApplication():
    """Create new WSGIApplication and register all handlers.

    Returns:
        an instance of webapp.WSGIApplication with all fantasm handlers registered.
    """
    # TODO: need to walk the source tree and find all files named *_ft.py

    # /hames - list all the functional tests
    # GET /hames/test/review-test - gets a form
    # POST /hames/test/review-test - process a form and return JSON

    # return webapp.WSGIApplication([
    #     (r"^/[^\/]+/fsm/.+",       handlers.FSMHandler),
    #     (r"^/[^\/]+/cleanup/",     handlers.FSMFanInCleanupHandler),
    #     (r"^/[^\/]+/graphviz/.+",  handlers.FSMGraphvizHandler),
    #     (r"^/[^\/]+/log/",         handlers.FSMLogHandler),
    #     (r"^/[^\/]+/?",            console.Dashboard),
    # ],
    # debug=True)

ROUTES = [
    webapp2.Route('/hames/ft/<testname>', 'hames.handlers.TestHandler'),
    webapp2.Route('/hames/<category>',    'hames.handlers.DashboardHandler'),
    webapp2.Route('/hames/',              'hames.handlers.DashboardHandler'),
]

APP = webapp2.WSGIApplication(ROUTES, debug=True)

# def main():
#     """ Main entry point. """
#     util.run_wsgi_app(APP)
#
# if __name__ == "__main__":
#     main()
